// purchase/keywords/keywords.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    goods_list:[],
    keywords:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (t) {
    getApp().page.onLoad(this, t);
    wx.setNavigationBarTitle({
      title: '搜索'
    })
  },
  ss:function(e){
    var a = this
    a.goods_list(a.data.keywords)
  },
  kw:function(e){
    console.log(e)
    var a = this 
    var ke = e.detail.value
    a.setData({
      keywords :ke
    })

  },
  goodsInfo: function (t) {
    console.log(t.currentTarget.dataset)
    var e = t.currentTarget.dataset.id
    getApp().core.navigateTo({
      url: "/purchase/goods_info/goods_info?id=" + e 
    });
  },
  goods_list: function (keywords) {
    var a = this;
    getApp().core.showLoading({
        title: "加载中"
    }), getApp().request({
        url: getApp().api.purchase.goods_list,
        data: {
            page: 1,
            // cat_id: cat_id,
            keywords:keywords
        },
        success: function (t) {
            if (0 === t.code) {
                var e = t.data.list;
                a.setData({
                    goods_list: e,
                    cats:t.data.cats
                })
            }
        },
        complete: function () {
            getApp().core.hideLoading();
        }
    });
},
  
})